﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DAL;

/// <summary>
/// Summary description for CostBO
/// </summary>
public class CostBO : DB_SAPDataContext
{
    public CostBO()
    {
        //
        // TODO: Add constructor logic here
        //
    }

    public int CostInsert(ZD_COST obj)
    {
        try
        {
            return ZD_PRC_ZD_COST_INSERT(obj.SOVANDON, obj.CREATEUSER);

        }
        catch
        {
            return -1;
        }
    }
    public int CostInputInsert(ZD_COST_INPUT obj)
    {
        try
        {
            return ZD_PRC_ZD_COST_INPUT_INSERT(obj.SOVANDON, obj.SOTOKHAI, obj.CREATEUSER);

        }
        catch
        {
            return -1;
        }
    }
    public bool Cost_Input_Update(ZD_COST_INPUT obj)
    {
        try
        {
            int rs=ZD_PRC_ZD_COST_INPUT_UPDATE(obj.ID,obj.SOTOKHAI,obj.UPDATEUSER);
            if (rs > 0)
                return true;
            else
            return false;
        }
        catch
        {
            return false;
        }
    }

    public List<ZD_PRC_ZD_COST_INPUT_GETALL_COSTResult> CostGetAll(int groupId)
    {
        try
        {
            List<ZD_PRC_ZD_COST_INPUT_GETALL_COSTResult> result = new List<ZD_PRC_ZD_COST_INPUT_GETALL_COSTResult>();
            result = ZD_PRC_ZD_COST_INPUT_GETALL_COST(groupId).ToList();
            return result;
        }
        catch (Exception ex)
        {
            return null;
        }
    }
    public int CostInputCheckSoVanDon(string sovandon)
    {
        try
        {
            return ZD_PRC_ZD_COST_INPUT_CHECK_SOVANDON(sovandon);

        }
        catch (Exception ex)
        {
            return -1;
        }
    }
    public int CostCheckSoVanDon(string sovandon)
    {
        try
        {
            return ZD_PRC_ZD_COST_CHECK_SOVANDON(sovandon);

        }
        catch (Exception ex)
        {
            return -1;
        }
    }
    

    public List<ZD_PRC_CHIPHI_GETResult> SearchChiPhi(int masterId)
    {
        try
        {
            List<ZD_PRC_CHIPHI_GETResult> result = new List<ZD_PRC_CHIPHI_GETResult>();
            result = ZD_PRC_CHIPHI_GET(masterId).ToList();
            return result;
        }
        catch (Exception ex)
        {
            return null;
        }
    }

    public int Cost_Input_BelongUpdate(ZD_COST_INPUT_BELONG obj,string dsChiPhiId, string dsSOTien)
    {
        try
        {
            return ZD_PRC_ZD_COST_INPUT_BELONG_UPDATE(obj.MASTERID, dsChiPhiId, dsSOTien, obj.CREATEUSER);

        }
        catch
        {
            return -1;
        }
    }
    public int Cost_Input_BelongInsert(ZD_COST_INPUT_BELONG obj, string dsChiPhiId, string dsSOTien)
    {
        try
        {
            return ZD_PRC_ZD_COST_INPUT_BELONG_INSERT(obj.MASTERID, dsChiPhiId, dsSOTien, obj.CREATEUSER);

        }
        catch
        {
            return -1;
        }
    }
    public int Cost_BelongInsert(ZD_COST_BELONG obj, string dsDOCENTRY)
    {
        try
        {
            return ZD_PRC_ZD_COST_BELONG_INSERT(obj.MASTERID, dsDOCENTRY, obj.CREATEUSER);

        }
        catch
        {
            return -1;
        }
    }
    public List<ZD_PRC_ZD_COST_DSCHIPHI_GETPHIResult> rpt_getPhiByGroupId(int masterId, int groupId)
    {
        try
        {
            List<ZD_PRC_ZD_COST_DSCHIPHI_GETPHIResult> result = new List<ZD_PRC_ZD_COST_DSCHIPHI_GETPHIResult>();
            result = ZD_PRC_ZD_COST_DSCHIPHI_GETPHI(masterId, groupId).ToList();
            return result;
        }
        catch (Exception ex)
        {
            return null;
        }
    }
    public List<ZD_PRC_RPT_ZD_COST_MASTERResult> rpt_getMasterByMasterId(int masterId)
    {
        try
        {
            List<ZD_PRC_RPT_ZD_COST_MASTERResult> result = new List<ZD_PRC_RPT_ZD_COST_MASTERResult>();
            result = ZD_PRC_RPT_ZD_COST_MASTER(masterId).ToList();
            return result;
        }
        catch (Exception ex)
        {
            return null;
        }
    }
    public List<ZD_PRC_RPT_ZD_COST_DETAILResult> rpt_getDetailByMasterId(int masterId)
    {
        try
        {
            List<ZD_PRC_RPT_ZD_COST_DETAILResult> result = new List<ZD_PRC_RPT_ZD_COST_DETAILResult>();
            result = ZD_PRC_RPT_ZD_COST_DETAIL(masterId).ToList();
            return result;
        }
        catch (Exception ex)
        {
            return null;
        }
    }
    public List<ZD_PRC_RPT_ZD_COST_DETAIL_GROUPResult> rpt_getDetailGroupByMasterId(int masterId)
    {
        try
        {
            List<ZD_PRC_RPT_ZD_COST_DETAIL_GROUPResult> result = new List<ZD_PRC_RPT_ZD_COST_DETAIL_GROUPResult>();
            result = ZD_PRC_RPT_ZD_COST_DETAIL_GROUP(masterId).ToList();
            return result;
        }
        catch (Exception ex)
        {
            return null;
        }
    }

    public List<ZD_PRC_ZD_COST_INPUT_SEARCHResult> Cost_Input_Search(DateTime tuNgay, DateTime denNgay, string SoVanDon)
    {
        try
        {
            List<ZD_PRC_ZD_COST_INPUT_SEARCHResult> result = new List<ZD_PRC_ZD_COST_INPUT_SEARCHResult>();
            result = ZD_PRC_ZD_COST_INPUT_SEARCH(tuNgay, denNgay, SoVanDon).ToList();
            return result;
        }
        catch (Exception ex)
        {
            return null;
        }
    }

    public List<ZD_PRC_ZD_COST_SEARCHResult> Cost_Search(DateTime tuNgay, DateTime denNgay, string SoVanDon)
    {
        try
        {
            List<ZD_PRC_ZD_COST_SEARCHResult> result = new List<ZD_PRC_ZD_COST_SEARCHResult>();
            result = ZD_PRC_ZD_COST_SEARCH(tuNgay, denNgay, SoVanDon).ToList();
            return result;
        }
        catch (Exception ex)
        {
            return null;
        }
    }
    public ZD_PRC_ZD_COST_INPUT_GETBY_IDResult Cost_Input_GetByMasterId(int masterId)
    {
        try
        {
            ZD_PRC_ZD_COST_INPUT_GETBY_IDResult result = new ZD_PRC_ZD_COST_INPUT_GETBY_IDResult();
            result = ZD_PRC_ZD_COST_INPUT_GETBY_ID(masterId).SingleOrDefault();
            return result;
        }
        catch (Exception ex)
        {
            return null;
        }
    }
    public ZD_PRC_ZD_COST_GETBY_IDResult Cost_GetByMasterId(int masterId)
    {
        try
        {
            ZD_PRC_ZD_COST_GETBY_IDResult result = new ZD_PRC_ZD_COST_GETBY_IDResult();
            result = ZD_PRC_ZD_COST_GETBY_ID(masterId).SingleOrDefault();
            return result;
        }
        catch (Exception ex)
        {
            return null;
        }
    }
    public List<ZD_PRC_ZD_COST_INPUT_BELONG_GETBY_IDResult> Cost_Input_Belong_GetByMasterId(int masterId, int groupId)
    {
        try
        {
            List<ZD_PRC_ZD_COST_INPUT_BELONG_GETBY_IDResult> result = new List<ZD_PRC_ZD_COST_INPUT_BELONG_GETBY_IDResult>();
            result = ZD_PRC_ZD_COST_INPUT_BELONG_GETBY_ID(masterId,groupId).ToList();
            return result;
        }
        catch (Exception ex)
        {
            return null;
        }
    }
    public List<ZD_PRC_ZD_GETINVOICEResult> Cost_XinPhep(string dsapno)
    {
        try
        {
            List<ZD_PRC_ZD_GETINVOICEResult> result = new List<ZD_PRC_ZD_GETINVOICEResult>();
            result = ZD_PRC_ZD_GETINVOICE(dsapno).ToList();
            return result;
        }
        catch (Exception ex)
        {
            return null;
        }
    }
}